package com.example.protestgps;

import org.json.JSONArray;
import org.json.JSONObject;

import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;

import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.util.Log;

public class EmerNotNull extends FragmentActivity{
	
	GoogleMap myMap;
	double latchange,lngchange;

	@Override
	protected void onCreate(Bundle arg0) {
		// TODO Auto-generated method stub
		super.onCreate(arg0);
		setContentView(R.layout.emergency);
		latchange = getIntent().getDoubleExtra("latchange", latchange);
		lngchange = getIntent().getDoubleExtra("lngchange", lngchange);
		
		
		SupportMapFragment mySupport = (SupportMapFragment) getSupportFragmentManager()
				.findFragmentById(R.id.map_canvas);
		myMap = mySupport.getMap();
		myMap.setMyLocationEnabled(true);
		CallHTTP(latchange, lngchange);
		posteremer(latchange, lngchange);
	}
	
	public void recdata(double _lat, double _lng, double curlat, double curlng,
			GoogleMap Map) {
		Log.d("_lat", "" + _lat);
		LatLng curpoint = new LatLng(curlat, curlng);
		LatLng despoint = new LatLng(_lat, _lng);
		Log.d("despoint", "" + despoint);
		Log.d("curpoint", "" + curpoint);
		Log.d("Map", "" + Map);
		Router routerr1 = new Router(Map, curpoint, despoint);

	}

	public void CallHTTP(double curlat, double curlng) {
		AsyncTask<String, String, String> AsyncTask1;
		JSONArray JsonArr;
		JSONObject JSONOBJ;
		LatLng despoint;
		HttpPostSvr task = new HttpPostSvr();
		// task.setdata();
		task.curpoint(curlat, curlng, myMap);
		AsyncTask1 = task.postter
				.execute("http://192.168.1.101/myexample/mytest1.php");

	}

	public void posteremer(double curlat, double curlng) {
		AsyncTask<String, String, String> AsyncTask1;
		JSONObject JSONOBJ;
		LatLng despoint;
		PosterEmer post = new PosterEmer();
		post.curpoint(curlat, curlng);
		AsyncTask1 = post.postsemer
				.execute("http://192.168.1.101/myexample/emerpost.php");
		Log.d("a1", "a1");
	}
	
	
	
}
